import 'package:flutter/material.dart';
import 'package:whale/helper/global/user/logic.dart';
import 'package:whale/helper/utils/util.dart';
import 'package:whale/pages/me/index.dart';

class PersonCard extends GetView<MeController> {
  const PersonCard({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var user = UserController().state.userObs;
    return InkWell(
      onTap: controller.goMeInfo,
      child: Container(
        padding: EdgeInsets.only(bottom: 15.r),
        decoration: BoxDecoration(
          image: DecorationImage(
              image: AssetImage('me_top.png'.imgPathMe), fit: BoxFit.cover),
          color: ColorsUtil.bg,
        ),
        child: Column(children: [
          SafeArea(
            child: Container(
              margin: EdgeInsets.only(top: 10.r),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    margin: EdgeInsets.only(left: 18.r),
                    child: GestureDetector(
                        onTap: () => Get.toNamed(RouterPath.qrcodeView),
                        child: Image.asset(
                          'icon_scan.png'.imgPathMe,
                          width: 20.r,
                          height: 20.r,
                        )),
                  ),
                  Row(
                    children: [
                      GestureDetector(
                          onTap: () => Get.toNamed(RouterPath.setup),
                          child: Image.asset(
                            'icon_setting.png'.imgPathMe,
                            width: 20.r,
                            height: 20.r,
                          )),
                      SizedBox(
                        width: 18.r,
                      ),
                      GestureDetector(
                          onTap: () => Get.toNamed(RouterPath.msgPage),
                          child: Image.asset(
                            'icon_notif.png'.imgPathMe,
                            width: 20.r,
                            height: 20.r,
                          )),
                      SizedBox(
                        width: 18.r,
                      )
                    ],
                  )
                ],
              ),
            ),
          ),
          SizedBox(
            height: 18.5.r,
          ),
          Obx(
            () => Row(
              children: [
                SizedBox(
                  width: 16.5.r,
                ),
                loadAvater(
                    url: 'assets/images/me/icon_setAvatar.png', size: 60.r),
                SizedBox(
                  width: 10.r,
                ),
                UserController().isLoginObs.value
                    ? Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            user.value.userName ?? '~~',
                            style: TextStyle(
                                color: const Color(0xff333333),
                                fontSize: 20.r,
                                fontWeight: FontWeight.bold),
                          ),
                          SizedBox(
                            height: 5.r,
                          ),
                          Text(
                            isZeroList(user.value.uiasRoleList)
                                ? '~~'
                                : user.value.uiasRoleList?.first.roleName ??
                                    '~~',
                            style: TextStyle(
                                color: const Color(0xff999999), fontSize: 12.r),
                          ),
                        ],
                      )
                    : Text(
                        '登录/注册',
                        style: TextStyle(
                            color: const Color(0xff333333),
                            fontSize: 20.sp,
                            fontWeight: FontWeight.bold),
                      ),
                Spacer(),
                Image.asset(
                  'icon_right.png'.imgPathMe,
                  width: 5.5.r,
                  height: 9.5.r,
                ),
                SizedBox(
                  width: 20.r,
                )
              ],
            ),
          )
        ]),
      ),
    );
  }
}
